﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC.Music.Data.Models;
using MVC.Music.Data;
using System.Threading.Tasks;
namespace MVC.MusicCMS.Web.Controllers
{
    public class BitrateController : BaseController
    {
        //
        // GET: /Track/
        public BitrateController()
        {
            ThisControllerLivesInWebsiteSection("bitrate");
        }
        //
        // GET: /Bitrate/

        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /Bitrate/Details/5
        [HttpGet]
        public JsonResult GetBitrates()
        {
            var listBitrateSelect = new List<SelectListItem>();
            var listBitrate = _bitrateRepository.Query();
            foreach (var b in listBitrate)
            {
                listBitrateSelect.Add(new SelectListItem()
                {
                    Selected = true,
                    Text = b.Name,
                    Value = b.BitrateID.ToString()

                });
            }
            return Json(listBitrateSelect, JsonRequestBehavior.AllowGet);
        }

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Bitrate/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Bitrate/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Bitrate/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Bitrate/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Bitrate/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Bitrate/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
